package model;

import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;

import data.Parameter;
import data.Project;

public class SimilarityFunction3 {

	static final double zeroPercentage = 3000;

	public static double similarityFunction(Project proj1, Project proj2) {
		double sum = 0;

		for (Entry<String, Parameter> e : proj1.params.entrySet()) {
			double val1 = e.getValue().dvalue;
			double val2 = proj2.params.get(e.getKey()).dvalue;
			sum += Math.abs(val1 - val2);
		}

		double simil = 1 - (sum / zeroPercentage);

		return simil;

	}

	public void intMinMax(Collection<Project> proj) {

		double max = 0;
		double min = 0;
		
		HashMap<String,Double> categoryMax = new HashMap<String,Double>();
		HashMap<String,Double> categoryMin = new HashMap<String,Double>();

		String[] fnames = Pharser.fnames;

		int categorySize = proj.iterator().next().params.size();

		for (int i = 0; i < categorySize; i++) {
			Iterator<Project> currProj = proj.iterator();

			while (currProj.hasNext()) {
				double value = currProj.next().params.get(fnames[i]).dvalue;
				if (value > max) {
					max = value;
				}
				if (value < min) {
					min = value;

				}	
				categoryMax.put(fnames[i], max);
				categoryMin.put(fnames[i], min);
			}
			
			
		}

	}

}
/*
 * increase 8 acap: analysts capability these to 10 pcap: programmers capability
 * decrease 9 aexp: application experience effort 13 modp: modern programing
 * practices 14 tool: use of software tools 11 vexp: virtual machine experience
 * 12 lexp: language experience
 * 
 * 15 sced: schedule constraint
 * 
 * decrease 5 stor: main memory constraint these to 2 data: data base size
 * decrease 4 time: time constraint for cpu effort 7 turn: turnaround time 6
 * virt: machine volatility 3 cplx: process complexity 1 rely: required software
 * reliability
 */

